package com.audaque.springboot.foshanupload.web.webdemo.controller;

import cn.hutool.core.net.url.UrlBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.URLEncoder;

/**
 * @author wangyan01
 */

@Slf4j
@RestController
@RequestMapping("string")
public class StringController {

    /**
     * 不支持正则表达式
     * @param str
     * @param target
     * @param replacement
     * @return
     */
    @GetMapping(value = "/replace")
    public String replace(String str, String target, String replacement) {
        return str.replace(target, replacement);
    }

    /**
     * 支持正则表达式
     * @param str
     * @param regex
     * @param replacement
     * @return
     */
    @GetMapping(value = "/replaceAll")
    public String replaceAll(String str, String regex, String replacement) {
        return str.replaceAll(regex, replacement);
    }

}
